#!/bin/bash # Description : This script removes ghostScript package from the machine using 'apt-get' command. # # Returns : 0 if successfully removed. # 2 if not successful. # # Usage : sh GhostscriptVulnerabilityForRpm.sh detect - for only detecting the ghostscript # sh GhostscriptVulnerabilityForRpm.sh - for only detecting and removing the ghostscript # # Example : sh GhostscriptVulnerabilityForRpm.sh detect # sh GhostscriptVulnerabilityForRpm.sh # # Maintainer : ManageEngine Desktop Central DetectOrDeploy="$1" # errorCodes # 0 for success # 2 for package uninstall failure errorCode=0 if [ "$DetectOrDeploy" = "detect" ] then RPM=$(rpm -qi ghostscript) X=`echo $?` CHECK="0" if [ $X -eq $CHECK ] then echo "Package GhostScript exist!" else echo "Package GhostScript does not exist!" errorCode=2 fi else # check whether ghostscript package exists and then proceed with removal RPM=$(rpm -qi ghostscript) X=`echo $?` CHECK="0" if [ $X -eq $CHECK ] then YUM=$(yum --assumeyes remove ghostscript) Y=`echo $?` # check whether package is removed successfully if [ $Y -eq $CHECK ] then echo "Package GhostScript removed successfully." else errorCode=2 echo "Error while removing Package GhostScript." fi else echo "Package GhostScript does not exist!" fi fi errorFunc(){ return $errorCode } errorFunc